// pages/radio/radio.js

import request from '../../utils/request'
Page({
  /**
   * 页面的初始数据
   */
  data: {
    recommendList: [], // 推荐歌单
    gexingList: [],//个性推荐
    catelist: [],//电台分类
    qingganList: [],//情感调频
    shengyinList: [],//声音恋人
    yinyueList: [],//音乐故事
    chuangzuoList: [],//创作翻唱
    shengzhiList: [],//声之剧场
    talkShowList: [],//脱口秀
    kankanList: [],//侃侃而谈
    dianyinList: [],//电音趴
    jieyaList: [],//解压助眠
    nihaoList: [],//你好爱豆
    soundsList: [],//铃声
    elseList: [],//其他
    navState: 0,//导航状态
  },
  //监听滑块
  bindchange(e) {
    // console.log(e.detail.current)
    let index = e.detail.current;
    this.setData({
      navState: index
    })
  },
  //点击导航
  navSwitch: function (e) {
    // console.log(e.currentTarget.dataset.index)
    let index = e.currentTarget.dataset.index;
    this.setData({
      navState: index
    })
  },

  /**
  * 生命周期函数--监听页面加载
  */
  onLoad: function (options) {
    this.nadaoShuju()
    this.gexingRecommend()
    this.requestLei()
    this.qingganTiaopin()
    this.yinyueGushi()
    this.shengyinLianren()
    this.chuangzuoFanchang()
    this.shengzhiJuchang()
    this.talkShow()
    this.kankanErtan()
    this.dianyinPa()
    this.jieyaZhumian()
    this.nihaoIdol()
    this.soundsRadio()
    this.elseRadio()
  },
  async nadaoShuju() {
    // 获取推荐歌单数据
    let recommendListData = await request('/personalized/djprogram', { limit: 6 });
    this.setData({
      recommendList: recommendListData.result
    })
    console.log(this.data.recommendList)
  },
  async gexingRecommend() {
    // 获取个性推荐数据
    let gexingListData = await request('/dj/personalize/recommend', { limit: 6 });
    console.log(gexingListData)
    this.setData({
      gexingList: gexingListData.data
    })
    console.log(this.data.gexingList)
  },
  async requestLei() {
    // 获取电台分类数据
    let catelist1 = await request('/dj/catelist');
    this.setData({
      catelist: catelist1.categories
    })
    console.log(this.data.catelist)
  },
  async qingganTiaopin() {
    // 获取情感调频数据
    let qingganListData = await request('/dj/recommend/type?type=3');
    console.log(qingganListData)
    this.setData({
      qingganList: qingganListData.djRadios
    })
    console.log(this.data.qingganList)
  },
  async yinyueGushi() {
    // 获取音乐故事数据
    let yinyueListData = await request('/dj/recommend/type?type=2');
    console.log(yinyueListData)
    this.setData({
      yinyueList: yinyueListData.djRadios
    })
    console.log(this.data.yinyueList)
  },
  async shengyinLianren() {
    // 获取声音恋人数据
    let shengyinListData = await request('/dj/recommend/type?type=3001');
    console.log(shengyinListData)
    this.setData({
      shengyinList: shengyinListData.djRadios
    })
    console.log(this.data.shengyinList)
  },
  async chuangzuoFanchang() {
    // 获取创作翻唱数据
    let chuangzuoListData = await request('/dj/recommend/type?type=2001');
    console.log(chuangzuoListData)
    this.setData({
      chuangzuoList: chuangzuoListData.djRadios
    })
    console.log(this.data.chuangzuoList)
  },
  async shengzhiJuchang() {
    // 获取声之剧场数据
    let shengzhiListData = await request('/dj/recommend/type?type=10001');
    console.log(shengzhiListData)
    this.setData({
      shengzhiList: shengzhiListData.djRadios
    })
    console.log(this.data.shengzhiList)
  },
  async talkShow() {
    // 获取脱口秀数据
    let talkShowListData = await request('/dj/recommend/type?type=8');
    console.log(talkShowListData)
    this.setData({
      talkShowList: talkShowListData.djRadios
    })
    console.log(this.data.talkShowList)
  },
  async kankanErtan() {
    // 获取侃侃而谈数据
    let kankanListData = await request('/dj/recommend/type?type=5');
    console.log(kankanListData)
    this.setData({
      kankanList: kankanListData.djRadios
    })
    console.log(this.data.kankanList)
  },
  async dianyinPa() {
    // 获取电音趴数据
    let dianyinListData = await request('/dj/recommend/type?type=10002');
    console.log(dianyinListData)
    this.setData({
      dianyinList: dianyinListData.djRadios
    })
    console.log(this.data.dianyinList)
  },
  async jieyaZhumian() {
    // 获取解压助眠数据
    let jieyaListData = await request('/dj/recommend/type?type=6');
    console.log(jieyaListData)
    this.setData({
      jieyaList: jieyaListData.djRadios
    })
    console.log(this.data.jieyaList)
  },
  async nihaoIdol() {
    // 获取你好爱豆数据
    let nihaoListData = await request('/dj/recommend/type?type=14');
    console.log(nihaoListData)
    this.setData({
      nihaoList: nihaoListData.djRadios
    })
    console.log(this.data.nihaoList)
  },
  async soundsRadio() {
    // 获取铃声数据
    let soundsListData = await request('/dj/recommend/type?type=13');
    console.log(soundsListData)
    this.setData({
      soundsList: soundsListData.djRadios
    })
    console.log(this.data.soundsList)
  },
  async elseRadio() {
    // 获取其他数据
    let elseListData = await request('/dj/recommend/type?type=11');
    console.log(elseListData)
    this.setData({
      elseList: elseListData.djRadios
    })
    console.log(this.data.elseList)
  },

  // 跳转至搜索界面
  toSearch() {
    wx.navigateTo({
      url: '/pages/search/search'
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})